<?php
/**
 * @name PushController
 * @author root
 * @desc 个推推送
 */
class PushController extends Yaf_Controller_Abstract{
    public function singleAction(){
        if(!$this->_isAdmin()){
            echo json_encode( array("errno"=>-7001, "errmsg"=>"仅管理员可以进行此操作") );
            return FALSE;
        }

        $cid = $this->getRequest()->getQuery( "cid", "" );
        $msg = $this->getRequest()->getQuery( "msg", "" );
        if( !$cid || !$msg ) {
            echo json_encode( array("errno"=>-7002, "errmsg"=>"请输入推送用户的设备ID与要推送的内容") );
            return FALSE;
        }

        // 调用Model
        $model = new PushModel();
        if ( $model->single( $cid, $msg ) ) {
            echo json_encode( array(
                "errno"=>0,
                "errmsg"=>"",
            ));
        } else {
            echo json_encode( array(
                "errno"=>$model->errno,
                "errmsg"=>$model->errmsg,
            ));
        }
        return TRUE;
    }
}